import request from '@/utils/request'
import {object2Url} from '@/utils/trans'

/**
 * 查询用户文件列表——热榜音乐
 */
export async function musicCollect (username) {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua,
    username: username
  }
  let url = `/business/montage/music/collect${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000 && res.data.data) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}

// 热榜音乐获取
export async function musicList (mcid,username) {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua,
    mcid,
    username: username
  }
  let url = `/business/montage/music/list${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000 && res.data.data) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}
